<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>nih: Trees</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nih
   &#160;<span id="projectnumber">0.5</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__trees.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Trees</div>  </div>
</div>
<div class="contents">
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structnih_1_1breadth__first__tree.html">nih::breadth_first_tree</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structnih_1_1depth__first__tree.html">nih::depth_first_tree</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structnih_1_1_b_f_tree.html">nih::BFTree&lt; Node_iterator, Domain_type &gt;</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">A simple Breadth-First Tree model implementation.  <a href="structnih_1_1_b_f_tree.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memTemplParams" colspan="2">template&lt;typename Tree , typename Input_iterator , typename Output_iterator , typename Operator &gt; </td></tr>
<tr><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__trees.html#gaa9d77543c5662fa5fc19d34fbcffece1">nih::cuda::tree_reduce</a> (const Tree tree, const Input_iterator in_values, Output_iterator leaf_values, Output_iterator node_values, const Operator op, const typename std::iterator_traits&lt; Output_iterator &gt;::value_type def_value)</td></tr>
<tr><td class="memTemplParams" colspan="2">template&lt;typename Tree , typename Input_iterator , typename Output_iterator , typename Operator &gt; </td></tr>
<tr><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__trees.html#ga623ca32c63710202fea743670faeee28">nih::cuda::tree_reduce</a> (const Tree tree, const Input_iterator in_values, Output_iterator node_values, const Operator op)</td></tr>
</table>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gaa9d77543c5662fa5fc19d34fbcffece1"></a><!-- doxytag: member="nih::cuda::tree_reduce" ref="gaa9d77543c5662fa5fc19d34fbcffece1" args="(const Tree tree, const Input_iterator in_values, Output_iterator leaf_values, Output_iterator node_values, const Operator op, const typename std::iterator_traits&lt; Output_iterator &gt;::value_type def_value)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Tree , typename Input_iterator , typename Output_iterator , typename Operator &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void nih::cuda::tree_reduce </td>
          <td>(</td>
          <td class="paramtype">const Tree&#160;</td>
          <td class="paramname"><em>tree</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Input_iterator&#160;</td>
          <td class="paramname"><em>in_values</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Output_iterator&#160;</td>
          <td class="paramname"><em>leaf_values</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Output_iterator&#160;</td>
          <td class="paramname"><em>node_values</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Operator&#160;</td>
          <td class="paramname"><em>op</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const typename std::iterator_traits&lt; Output_iterator &gt;::value_type&#160;</td>
          <td class="paramname"><em>def_value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Reduce a bunch of values attached to the elemens in the leaves of a tree. The Tree template type has to provide the following breadth-first tree interface:</p>
<div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>Tree
 {
     <span class="comment">// return the number of levels</span>
     uint32 get_level_count() <span class="keyword">const</span>;

     <span class="comment">// return the index of the first node in the i-th level</span>
     uint32 get_level(<span class="keyword">const</span> uint32 i) <span class="keyword">const</span>;

     <span class="comment">// retrieve a node</span>
     node_type get_node(<span class="keyword">const</span> uint32 index) <span class="keyword">const</span>;

     <span class="comment">// return the number of leaves</span>
     uint32 get_leaf_count() <span class="keyword">const</span>;

     <span class="comment">// retrieve a leaf</span>
     uint2 get_leaf(<span class="keyword">const</span> uint32 index) <span class="keyword">const</span>;
 };
</pre></div><p>The following code snippet illustrates an example usage:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor"> #include &lt;nih/tree/cuda/tree_reduce.h&gt;</span>
<span class="preprocessor"> #include &lt;nih/tree/model.h&gt;</span>

 <span class="keyword">struct </span>merge_op
 {
     NIH_HOST_DEVICE Bbox4f operator() (
         <span class="keyword">const</span> Bbox4f op1,
         <span class="keyword">const</span> Bbox4f op2)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> Bbox4f( op1, op2 ); }
 };

 <span class="comment">// compute the bboxes of a tree</span>
 <span class="keywordtype">void</span> compute_bboxes(
     uint32      node_count,     <span class="comment">// input tree nodes</span>
     uint32      leaf_count,     <span class="comment">// input tree leaves</span>
     uint32      level_count,    <span class="comment">// input tree levels</span>
     Bvh_node*   nodes,          <span class="comment">// input tree nodes, device pointer</span>
     uint2*      leaves,         <span class="comment">// input tree leaves, device pointer</span>
     uint32*     levels,         <span class="comment">// input tree levels, host pointer</span>
     Bbox4f*     bboxes,         <span class="comment">// input primitive bboxes, device pointer</span>
     Bbox4f*     node_bboxes,    <span class="comment">// output node bboxes, device pointer</span>
     Bbox4f*     leaf_bboxes)    <span class="comment">// output leaf bboxes, device pointer</span>
 {
     <span class="comment">// instantiate a breadth-first tree view</span>
     BFTree&lt;Bvh_node*,device_domain&gt; bvh(
         nodes,
         leaf_count,
         leaves,
         level_count,
         levels );

     <span class="comment">// compute a tree reduction</span>
     <a class="code" href="group__trees.html#gaa9d77543c5662fa5fc19d34fbcffece1">cuda::tree_reduce</a>(
         bvh,
         bboxes,
         leaf_bboxes,
         node_bboxes,
         merge_op(),
         Bbox4f() );
 }
</pre></div> 
</div>
</div>
<a class="anchor" id="ga623ca32c63710202fea743670faeee28"></a><!-- doxytag: member="nih::cuda::tree_reduce" ref="ga623ca32c63710202fea743670faeee28" args="(const Tree tree, const Input_iterator in_values, Output_iterator node_values, const Operator op)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Tree , typename Input_iterator , typename Output_iterator , typename Operator &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void nih::cuda::tree_reduce </td>
          <td>(</td>
          <td class="paramtype">const Tree&#160;</td>
          <td class="paramname"><em>tree</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Input_iterator&#160;</td>
          <td class="paramname"><em>in_values</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Output_iterator&#160;</td>
          <td class="paramname"><em>node_values</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const Operator&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Reduce a bunch of values attached to the leaves of a tree. </p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Thu Dec 15 2011 11:56:21 for nih by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
